import { type } from "jquery";
import {
    queryDeptRender,
    queryRoleRender,
    queryUserRender,
    queryPatientRender,
    queryDiagnosisRender,
    queryOrderItemRender 
} from "./formRender";
const STATUS = [
    {key: true, label: '启用'},
    {key: false, label: '禁用'},
]
export const formFieldDoctor = {
    // 部门，科室，模糊搜索
    depart(label, key, config = {}, renderItemConfig = {}) {
        label = label || "所属科室";
        key = key || "departmentId";

        let itemConfig = {
            label: label,
            key: key,
            type: "render",
            render: this.$getOnceItem(key, () =>
                queryDeptRender(
                    _.merge(
                        {},
                        {
                            selectConfig: {
                                autoLoad: true,
                                params: {},
                                isMultiple: false,
                            },
                            nullQuerySign: true, // 查询条件为null时是否要查询数据
                        },
                        renderItemConfig
                    )
                )
            ),

            ...config,
        };
        return itemConfig;
    },
    // 角色
    role(label, key, config = {}, renderItemConfig = {}) {
        label = label || "所属角色";
        key = key || "roleId";

        let itemConfig = {
            label: label,
            key: key,
            type: "render",
            render: this.$getOnceItem(key, () =>
                queryRoleRender(
                    _.merge(
                        {},
                        {
                            selectConfig: {
                                autoLoad: true,
                                params: {},
                                isMultiple: false,
                            },
                            nullQuerySign: true, // 查询条件为null时是否要查询数据
                        },
                        renderItemConfig
                    )
                )
            ),

            ...config,
        };
        return itemConfig;
    },
    // 医生用户
    user(label, key, config = {}, renderItemConfig = {}) {
        label = label || "用户";
        key = key || "userId";

        let itemConfig = {
            label: label,
            key: key,
            type: "render",
            render: this.$getOnceItem(key, () =>
                queryUserRender(
                    _.merge(
                        {},
                        {
                            selectConfig: {
                                autoLoad: true,
                                params: {},
                                isMultiple: false,
                            },
                            nullQuerySign: true, // 查询条件为null时是否要查询数据
                        },
                        renderItemConfig
                    )
                )
            ),

            ...config,
        };
        return itemConfig;
    },
    // 患者用户
    patient(label, key, config = {}, renderItemConfig = {}) {
        label = label || "患者";
        key = key || "patientId";

        let itemConfig = {
            label: label,
            key: key,
            type: "render",
            render: this.$getOnceItem(key, () =>
                queryPatientRender(
                    _.merge(
                        {},
                        {
                            selectConfig: {
                                autoLoad: true,
                                params: {},
                                isMultiple: false,
                            },
                            nullQuerySign: true, // 查询条件为null时是否要查询数据
                        },
                        renderItemConfig
                    )
                )
            ),

            ...config,
        };
        return itemConfig;
    },
    // 诊断
    diagnosis(label, key, config = {}, renderItemConfig = {}) {
        label = label || "诊断";
        key = key || "diagnosisCode";

        let itemConfig = {
            label: label,
            key: key,
            type: "render",
            render: this.$getOnceItem(key, () =>
                queryDiagnosisRender(
                    _.merge(
                        {},
                        {
                            selectConfig: {
                                autoLoad: true,
                                params: {},
                                isMultiple: false,
                            },
                            nullQuerySign: true, // 查询条件为null时是否要查询数据
                        },
                        renderItemConfig
                    )
                )
            ),

            ...config,
        };
        return itemConfig;
    },
    // 医嘱
    orderItem(label, key, config = {}, renderItemConfig = {}) {
        label = label || "医嘱";
        key = key || "diagnosisCode";

        let itemConfig = {
            label: label,
            key: key,
            type: "render",
            render: this.$getOnceItem(key, () =>
                queryOrderItemRender(
                    _.merge(
                        {},
                        {
                            selectConfig: {
                                autoLoad: true,
                                params: {},
                                isMultiple: false,
                            },
                            nullQuerySign: true, // 查询条件为null时是否要查询数据
                        },
                        renderItemConfig
                    )
                )
            ),

            ...config,
        };
        return itemConfig;
    },
    status(label, key, config, callback) {
        let itemConfig = {
            key: key || "status",
            label: label || "状态",
            type: "select",
            options: STATUS,
            ...config,
        };
        return itemConfig;
    },
    password(label, key, config, callback) {
        let itemConfig = {
            key: key || "password",
            label: label || "密码",
            type: "input",
            props: {

                type: "password",
                "show-password": true,
            },
            ...config,
        };
        return itemConfig;
    },
}